package org.example.SolutionNew001;

public class DoublePoint02 {
    public static void main(String[] args) {
        DoublePoint02 dp = new DoublePoint02();
        int[] nums=new int[]{1,8};
        System.out.println(dp.maxArea(nums));
    }

    public int maxArea(int[] height) {
        int n=height.length,left=0,right=n-1;
        int res=0;
        while (left < right) {
            int area=Math.min(height[left],height[right])*(right-left);
            res=Math.max(res,area);
            if(height[left]<height[right]){
                left++;
            }else{
                right--;
            }
        }
        return res;
    }
}
